<%@page contentType="text/html;charset=utf-8"%>
<%@taglib prefix="s" uri="/struts-tags"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>生成订单 - 当当网</title>
<link rel="stylesheet" href="../css/style.css" type="text/css"></link>
<link href="../css/login.css" rel="stylesheet" type="text/css" />
<link href="../css/page_bottom.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="../js/jquery-1.7.2.min.js"></script>
<script  src="../js/Validform_v5.0_min.js" type="text/javascript"></script>
<script>
	$(function() {
		$('#address').change(function() {
			var addressId = $(this).val();
			//$('#index').val(addressId);
			if (addressId == -1) {
				$('#id').val(addressId);
				$('#userId').val('');
				$('#receiveName').val('');
				$('#fullAddress').val('');
				$('#postalCode').val('');
				$('#phone').val('');
				$('#mobile').val('');
				$('#phone').val('');
			} else {
				$.ajax({
					url : "../order/getaddress",
					async : false,//请求同步处理
					data : {
						"aid" : addressId
					},
					success : function(data) {//data获取的是action返回的json数据
						$('#id').val(data.id);
						$('#userId').val(data.userId);
						$('#receiveName').val(data.receiveName);
						$('#fullAddress').val(data.fullAddress);
						$('#postalCode').val(data.postalCode);
						$('#phone').val(data.phone);
						$('#mobile').val(data.mobile);
						$('#phone').val(data.postalCode);
					}
				});
			}
		});

	});
	$(function() {
		$('.f').Validform({
			tiptype : 2,
			datatype:{//传入自定义datatype类型【方式二】;
			"z2-4" : /^[\u4E00-\u9FA5\uf900-\ufa2d]{2,4}$/ ,
			"phone" : /^[0-9]{8}$/
			}
		});

	});
</script>
</head>
<body>
	<%@include file="../common/head1.jsp"%>
	<div class="login_step">
		生成订单骤: 1.确认订单 > <span class="red_bold"> 2.填写送货地址</span> > 3.订单成功
	</div>
	<div class="fill_message">
		<p>
			选择地址： <select id="address">
				<option value="-1">填写新地址</option>
				<s:iterator value="addressList">
					<option value="${id }">
						<s:property value="receiveName" />
					</option>
				</s:iterator>
			</select>
		</p>
		<form name="ctl00" method="post"
			action="${pageContext.request.contextPath}/order/finishorder" id="f" class="f">

			<input type="hidden" name="address.id" id="id" value="-1" />
			<table class="tab_login">
				<tr>
					<td valign="top" class="w1">收件人姓名：</td>
					<td><input type="text" class="text_input"
						name="address.receiveName" id="receiveName" 
						datatype="z2-4" errormsg="请输入2~4个中文字符" nullmsg="请输入收件人姓名"/>
					</td>
					<td>
						<div class="text_left" id="nameValidMsg">
							<div class="Validform_checktip">请填写有效的收件人姓名,中文名为2~4个中文字符</div>
						</div>
					</td>
				</tr>
				<tr>
					<td valign="top" class="w1">收件人详细地址：</td>
					<td><input type="text" name="address.fullAddress"
						class="text_input" id="fullAddress" 
						datatype="*" nullmsg="请输入收件人详细地址"/>
					</td>
					<td>
						<div class="text_left" id="nameValidMsg">
							<div class="Validform_checktip">请填写有效的收件人的详细地址</div>
						</div>
					</td>
				</tr>
				<tr>
					<td valign="top" class="w1">邮政编码</td>
					<td><input type="text" class="text_input"
						name="address.postalCode" id="postalCode" 
						datatype="p" errormsg="请输入正确邮政编码" nullmsg="请输入邮政编码"/>
					</td>
					<td>
						<div class="text_left" id="nameValidMsg">
							<div class="Validform_checktip">请填写有效的收件人的邮政编码</div>
						</div>
					</td>
				</tr>
				<tr>
					<td valign="top" class="w1">电话</td>
					<td><input type="text" class="text_input" name="address.phone"
						id="phone" 
						datatype="phone" errormsg="请输入8位电话号码" nullmsg="请输入电话号码"/>
					</td>
					<td>
						<div class="text_left" id="nameValidMsg">
							<div class="Validform_checktip">请填写有效的收件人的电话，电话号码为8位数字</div>
						</div>
					</td>
				</tr>
				<tr>
					<td valign="top" class="w1">手机</td>
					<td><input type="text" class="text_input"
						name="address.mobile" id="mobile" 
						datatype="m" errormsg="请输入正确手机号码" nullmsg="请输入手机号码"/>
					</td>
					<td>
						<div class="text_left" id="nameValidMsg">
							<div class="Validform_checktip">请填写有效的收件人的手机，手机号码为11位数字</div>
						</div>
					</td>
				</tr>
			</table>

			<div class="login_in">

				<a href="order_info.jsp"><input id="btnClientRegister"
					class="button_1" name="submit" type="submit" value="取消" /> </a> <input
					id="btnClientRegister" class="button_1" name="submit" type="submit"
					value="下一步" />
			</div>
		</form>
	</div>
	<%@include file="../common/foot1.jsp"%>
</body>
</html>

